.Container {
  width: 16rem;
  margin: 0 auto;
}

.InputGroup {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.TextInput {
  box-sizing: border-box;
  padding-left: 0.875rem;
  margin: 0;
  border: 1px solid var(--color-gray-200);
  flex: 1;
  height: 2.5rem;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 1rem;
  background-color: canvas;
  color: var(--color-gray-900);
  outline: none;

  &:focus {
    border-color: var(--color-blue);
    outline: 1px solid var(--color-blue);
  }
}

.EmojiButton {
  box-sizing: border-box;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--color-gray-200);
  border-radius: 0.375rem;
  background-color: canvas;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--color-gray-900);
  outline: none;

  &:hover {
    background-color: var(--color-gray-100);
  }

  &:focus-visible {
    border-color: var(--color-blue);
    outline: 2px solid var(--color-blue);
    outline-offset: -1px;
  }

  &[data-popup-open] {
    background-color: var(--color-gray-100);
  }
}

.Trigger {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  height: 2.5rem;
  padding-left: 0.875rem;
  padding-right: 0.75rem;
  margin: 0;
  outline: 0;
  border: 1px solid var(--color-gray-200);
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5rem;
  color: var(--color-gray-900);
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
  min-width: 9rem;
  background-color: canvas;

  @media (hover: hover) {
    &:hover {
      background-color: var(--color-gray-100);
    }
  }

  &[data-popup-open] {
    background-color: var(--color-gray-100);
  }

  &:focus-visible {
    outline: 2px solid var(--color-blue);
    outline-offset: -1px;
  }
}

.TriggerIcon {
  display: flex;
}

.InputContainer {
  box-sizing: border-box;
  width: 16rem;
  height: calc(var(--input-container-height));
  text-align: center;
  background: canvas;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0.25rem;
}

.Input {
  box-sizing: border-box;
  padding-left: 0.875rem;
  margin: 0;
  border: 1px solid var(--color-gray-300);
  width: 100%;
  height: 2.5rem;
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 1rem;
  background-color: canvas;
  color: var(--color-gray-900);
  outline: none;

  &:focus {
    border-color: var(--color-blue);
    outline: 1px solid var(--color-blue);
  }
}

.Positioner {
  outline: 0;
}

.Popup {
  --input-container-height: 3rem;
  box-sizing: border-box;
  border-radius: 0.5rem;
  background-color: canvas;
  color: var(--color-gray-900);
  transform-origin: var(--transform-origin);
  transition:
    transform 150ms,
    opacity 150ms;
  max-width: var(--available-width);
  max-height: 20.5rem;

  &[data-starting-style],
  &[data-ending-style] {
    opacity: 0;
    transform: scale(0.9);
  }

  @media (prefers-color-scheme: light) {
    outline: 1px solid var(--color-gray-200);
    box-shadow:
      0 10px 15px -3px var(--color-gray-200),
      0 4px 6px -4px var(--color-gray-200);
  }

  @media (prefers-color-scheme: dark) {
    outline: 1px solid var(--color-gray-300);
  }
}

.List {
  overflow: auto;
  scroll-padding-top: 2.5rem;
  scroll-padding-bottom: 0.35rem;
  overscroll-behavior: contain;
  max-height: min(
    calc(20.5rem - var(--input-container-height)),
    calc(var(--available-height) - var(--input-container-height))
  );

  &:empty {
    padding: 0;
  }
}

.ListContainer {
  padding: 0.5rem;
}

.GroupLabel {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-gray-600);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  background-color: canvas;
  border-bottom: 1px solid var(--color-gray-100);
  position: sticky;
  z-index: 1;
  top: 0;
  margin: 0;
  width: 100%;
}

.Group {
  display: block;
}

.Grid {
  padding: 0.25rem;
}

.Row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), 1fr);
}

.Item {
  outline: 0;
  cursor: default;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: var(--anchor-width);
  height: 2.5rem;
  padding: 0.5rem 0.125rem;
  border-radius: 0.375rem;
  background: transparent;

  &[data-highlighted] {
    z-index: 0;
    position: relative;
    color: var(--color-gray-50);

    &::before {
      content: '';
      z-index: -1;
      position: absolute;
      inset: 0;
      border-radius: 0.375rem;
      background-color: var(--color-gray-200);
    }
  }
}

.Emoji {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.Name {
  font-size: 0.625rem;
  text-align: center;
  opacity: 0.8;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.Item[data-highlighted] .Name {
  opacity: 1;
}

.Empty:not(:empty) {
  box-sizing: border-box;
  padding: 0.5rem 1rem 1rem;
  font-size: 0.925rem;
  line-height: 1rem;
  color: var(--color-gray-600);
}
